using System;
using Gtk;

public partial class MainWindow: Gtk.Window
{	
	public MainWindow (): base (Gtk.WindowType.Toplevel)
	{
		Build ();
	}

	protected void OnDeleteEvent (object sender, DeleteEventArgs a)
	{
		Application.Quit ();
		a.RetVal = true;
	}

	protected void OnOpen (object sender, EventArgs e)
	{
		int width, height;
		this.GetDefaultSize (out width, out height);
		this.Resize (width, height);
		// Create and display a fileChooserDialog
		FileChooserDialog chooser = new FileChooserDialog(
			"Please select a sourcefile to open ...",
			this,
			FileChooserAction.Open,
			"cancel", ResponseType.Cancel,
			"view", ResponseType.Accept );

		if (chooser.Run () == (int)ResponseType.Accept) {
			System.IO.StreamReader file =
				System.IO.File.OpenText (chooser.Filename);
			logTextView.Buffer.Text = file.ReadToEnd ();
			this.Title = " ssource viewer -- " + chooser.Filename.ToString ();
			this.Resize (640, 480);
			file.Close ();
		} 
		chooser.Destroy ();
	}

	protected void OnExit (object sender, EventArgs e)
	{
		Application.Quit ();
	}

	protected void OnAbout (object sender, EventArgs e)
	{
		AboutDialog about = new AboutDialog ();
		about.ProgramName = "ssource view";
		about.Version = "1.1.0";
		about.Run ();
		about.Destroy ();
	}
}
